"""
配置类,读取配置信息
"""
import configparser
import os


class Setting:

    def __init__(self, path=None):
        if not path:
            base_path = os.path.dirname(os.path.abspath(os.path.dirname(__file__)))
            self.config_path = os.path.join(base_path, 'config/config.ini')
        else:
            self.config_path = path
        self.config = configparser.ConfigParser()
        self.config.read(self.config_path, encoding='utf-8')
        self.setting()

    def setting(self):
        for attr in self.config.sections():
            self.__dict__[attr] = dict(self.config.items(attr))


setting = Setting()
